import { http } from '@/utils/http/axios';

// /**
//  * @description: 角色列表
//  */
// export function getRoleList() {
//   return http.request({
//     url: '/role/list',
//     method: 'GET',
//   });
// }

/**
 * 新接口
 * @param query
 * @returns
 */
export function fetchList(query) {
  return http.request({
    url: '/admin/role/page',
    method: 'post',
    params: query,
  });
}

export function deptRoleList() {
  return http.request({
    url: '/admin/role/list',
    method: 'get',
  });
}

export function getObj(id) {
  return http.request({
    url: '/admin/role/' + id,
    method: 'get',
  });
}

export function addObj(obj) {
  return http.request({
    url: '/admin/role/create',
    method: 'post',
    data: obj,
  });
}

export function putObj(obj) {
  return http.request({
    url: '/admin/role',
    method: 'put',
    data: obj,
  });
}

export function delObj(id) {
  return http.request({
    url: '/admin/role/' + id + '/delete',
    method: 'delete',
  });
}

export function permissionUpd(roleId, menuIds) {
  return http.request({
    url: '/admin/role/menu',
    method: 'put',
    data: {
      roleId: roleId,
      menuIds: menuIds,
    },
  });
}

export function fetchRoleTree(roleName) {
  return http.request({
    url: '/admin/menu/tree/' + roleName,
    method: 'get',
  });
}
